package com.zhsj.OkeHomeConsumption.ui.activity.wallet;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.adapter.InviteItemAdapter;
import com.zhsj.OkeHomeConsumption.empty.Wallet;

import java.util.List;

/**
 * Created by zwj on 2018/3/13.
 */

public class InviteExpectMoneyAdapter extends BaseAdapter {

    private Context context;
    private List<Wallet> list;
    private LayoutInflater mLayoutInflater;
    private InviteItemAdapter mInviteItemAdapter;

    public InviteExpectMoneyAdapter(Context context, List<Wallet> walletList) {
        this.context = context;
        this.list = walletList;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.item_money_invite, null);
            viewHolder.name_text = (TextView) convertView.findViewById(R.id.name_text);
            viewHolder.list_item = (NoScrollListView) convertView.findViewById(R.id.list_item);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final Wallet item = list.get(position);

        if (item != null) {
            viewHolder.name_text.setText(item.getName());
            mInviteItemAdapter = new InviteItemAdapter(context, item.getList());
            viewHolder.list_item.setAdapter(mInviteItemAdapter);
        }
        return convertView;
    }


    class ViewHolder {
        private TextView name_text;
        private NoScrollListView list_item;
    }
}